home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / dns / ddt2.0 / cmd / hosts-domain < prev    next >
Encoding:
Text File  |  1993-05-17  |  1.4 KB  |  47 lines

  1. #!/usr/local/bin/perl
  2. #
  3. #  hosts-domain - counts the number of hosts per domain
  4. #                The host names should be absolute (see expand) and in the
  5. #          first column of input (see hosts)
  6. #
  7. #  Copyright (C) 1992, 1993 PUUG - Grupo Portugues de Utilizadores
  8. #                                  do Sistema UNIX
  9. #                1992, 1993 FCCN - Fundacao para o Desenvolvimento dos Meios 
  10. #                                  Nacionais de Calculo Cientifico 
  11. #
  12. #  Authors: Jorge Frazao de Oliveira <frazao@puug.pt>
  13. #           Artur Romao <artur@dns.pt>
  14. #
  15. #  This file is part of the DDT package, Version 2.0.
  16. #
  17. #  Permission to use, copy, modify, and distribute this software and its 
  18. #  documentation for any purpose and without any fee is hereby granted,
  19. #  provided that the above copyright notice appear in all copies.  Neither
  20. #  PUUG nor FCCN make any representations about the suitability of this
  21. #  software for any purpose.  It is provided "as is" without express or 
  22. #  implied warranty.
  23.  
  24.  
  25. $[ = 1;            # set array base to 1
  26.  
  27. while (<STDIN>) {
  28.         ($Name) = split(/\s+/, $_);
  29.  
  30.         @label = split(/\./, $Name);
  31.     $n = $#label;
  32.  
  33.         $domain = $label[$n];    # topmost domain
  34.  
  35.         foreach $i ($[ .. $n - 1) {
  36.         $hosts{$domain}++;
  37.  
  38.         # build the domain name backwards
  39.         $domain = join(".", $label[$n - $i], $domain);
  40.         }
  41. }
  42.  
  43. foreach $dom (keys %hosts) {
  44.         printf "%5d %s\n", $hosts{$dom}, $dom;
  45. }
  46.  
  47.